package com.ruoyi.transport.service.impl;

import com.ruoyi.transport.domain.PurchaseTransport;
import com.ruoyi.transport.mapper.PurchaseTransportMapper;
import com.ruoyi.transport.service.IPurchaseTransportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 采购运输管理Service业务层处理
 * 
 * @author wkm
 * @date 2024/12/19
 */
@Service
public class PurchaseTransportServiceImpl implements IPurchaseTransportService 
{
    @Autowired(required = false)
    private PurchaseTransportMapper purchaseTransportMapper;

    /**
     * 查询采购运输管理
     * 
     * @param transportId 采购运输管理主键
     * @return 采购运输管理
     */
    @Override
    public PurchaseTransport selectPurchaseTransportByTransportId(Integer transportId)
    {
        return purchaseTransportMapper.selectPurchaseTransportByTransportId(transportId);
    }

    /**
     * 查询采购运输管理列表
     * 
     * @param purchaseTransport 采购运输管理
     * @return 采购运输管理
     */
    @Override
    public List<PurchaseTransport> selectPurchaseTransportList(PurchaseTransport purchaseTransport)
    {
        return purchaseTransportMapper.selectPurchaseTransportList(purchaseTransport);
    }

    /**
     * 新增采购运输管理
     * 
     * @param purchaseTransport 采购运输管理
     * @return 结果
     */
    @Override
    public int insertPurchaseTransport(PurchaseTransport purchaseTransport)
    {
        return purchaseTransportMapper.insertPurchaseTransport(purchaseTransport);
    }

    /**
     * 修改采购运输管理
     * 
     * @param purchaseTransport 采购运输管理
     * @return 结果
     */
    @Override
    public int updatePurchaseTransport(PurchaseTransport purchaseTransport)
    {
        return purchaseTransportMapper.updatePurchaseTransport(purchaseTransport);
    }

    /**
     * 批量删除采购运输管理
     * 
     * @param transportIds 需要删除的采购运输管理主键
     * @return 结果
     */
    @Override
    public int deletePurchaseTransportByTransportIds(Integer[] transportIds)
    {
        return purchaseTransportMapper.deletePurchaseTransportByTransportIds(transportIds);
    }

    /**
     * 删除采购运输管理信息
     * 
     * @param transportId 采购运输管理主键
     * @return 结果
     */
    @Override
    public int deletePurchaseTransportByTransportId(Integer transportId)
    {
        return purchaseTransportMapper.deletePurchaseTransportByTransportId(transportId);
    }

    @Override
    public void distributeMessage(PurchaseTransport purchaseTransport) {
        String transportMode = purchaseTransport.getTransportMode();
        String transportDriver = purchaseTransport.getTransportDriver();
        String transportDrivertel = purchaseTransport.getTransportDrivertel();
        PurchaseTransport transport = PurchaseTransport.builder()
                .transportMode(transportMode)
                .transportDriver(transportDriver)
                .transportDrivertel(transportDrivertel)
                .build();
        purchaseTransportMapper.insertPurchaseTransport(transport);
    }
}
